;;;Generate a sorted list of layer names in the drawing.
;;;
;;;	The list is written to a
;;;	file named <dwgname>.LAY in the current directory.
;;;	The list can be viewed in AutoCAD by entering
;;;	!newlist at the command prompt.  A page by page
;;;	listing can be viewed by entering LLIST after the
;;;	lay_list routine has been run.
;;;
;;;
;;;	AUTHOR: HENRY C. FRANCIS
;;;		425 N. ASHE ST.
;;;		SOUTHERN PINES, NC 28387
;;;              
;;;		All rights reserved without prejudice.
;;;
;;;	Copyright:	4-28-96
;;;	Edited:		1-31-2003
;;;
(defun c:laylst ( / it itn lay_f lay_str)
    (progn
      (setq it (tblnext "layer" "T"))
      (setq itn (cdr(assoc 2 it)))
      (setq newlist (list itn))
      (while
        (setq it (tblnext "layer"))
        (progn
          (setq itn (cdr(assoc 2 it)))
          (setq newlist (append newlist(list itn)))
        );progn
      );while
      (setq newlist (acad_strlsort newlist))
      (if (wcmatch (strcase (getvar "dwgname")) "*.DWG")
        (setq layfilenm (strcat(substr(getvar"dwgname")1(-(strlen(getvar"dwgname"))4))".LAY"))
        (setq layfilenm (strcat(getvar"dwgname")".LAY"))
      )
      (setq lay_f (open layfilenm "w"))
      (foreach n newlist (write-line n lay_f))
      (close lay_f)
    );progn
);defun
(defun C:LLIST ( / )
  (foreach n newlist
    (princ (strcat "\n" n)))
  (princ)
);defun
